﻿// Test_RollAngle_Dlg.cpp: 实现文件
//

#include "pch.h"
#include "SakerProject.h"
#include "Test_RollAngle_Dlg.h"
#include "afxdialogex.h"

#include "mmFile_Paras.h"
#include "xxFileProcess.h"
#include "xxWidgetControl.h"

// CTest_RollAngle_Dlg 对话框
CTest_RollAngle_Dlg * m_Test_RollAngle;

IMPLEMENT_DYNAMIC(CTest_RollAngle_Dlg, CDialogEx)

CTest_RollAngle_Dlg::CTest_RollAngle_Dlg(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_Test_RollAngle, pParent)
{

}

CTest_RollAngle_Dlg::~CTest_RollAngle_Dlg()
{
}

void CTest_RollAngle_Dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CTest_RollAngle_Dlg, CDialogEx)
	ON_BN_CLICKED(IDC_BUTTON_Save, &CTest_RollAngle_Dlg::OnBnClickedButtonSave)
	ON_EN_CHANGE(IDC_EDIT_Clip_xL, &CTest_RollAngle_Dlg::OnEnChangeEditClipxl)
	ON_EN_CHANGE(IDC_EDIT_Clip_xR, &CTest_RollAngle_Dlg::OnEnChangeEditClipxr)
	ON_EN_CHANGE(IDC_EDIT_Clip_yT, &CTest_RollAngle_Dlg::OnEnChangeEditClipyt)
	ON_EN_CHANGE(IDC_EDIT_Clip_yD, &CTest_RollAngle_Dlg::OnEnChangeEditClipyd)
	ON_CBN_SELCHANGE(IDC_COMBO_StepName, &CTest_RollAngle_Dlg::OnCbnSelchangeComboStepname)
END_MESSAGE_MAP()


// CTest_RollAngle_Dlg 消息处理程序


BOOL CTest_RollAngle_Dlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	((CSpinButtonCtrl*)GetDlgItem(IDC_SPIN_Clip_xL))->SetRange(0, 10000);
	((CSpinButtonCtrl*)GetDlgItem(IDC_SPIN_Clip_xR))->SetRange(0, 10000);
	((CSpinButtonCtrl*)GetDlgItem(IDC_SPIN_Clip_yT))->SetRange(0, 10000);
	((CSpinButtonCtrl*)GetDlgItem(IDC_SPIN_Clip_yD))->SetRange(0, 10000);

	CString iniField = mmTest_RollAngle.iniField;
	CString iniCurrentPath = mmFile_Paras.iniModelPath();

	mmTest_RollAngle.SelStep = xx::InitCB(this, IDC_COMBO_StepName, mmTest_RollAngle.vecStepNames, iniField, L"SelStep", iniCurrentPath, 0);
	mmTest_RollAngle.xL = xx::InitWidget(this, IDC_EDIT_Clip_xL, iniField, L"Clip_xL", iniCurrentPath, 0);
	mmTest_RollAngle.xR = xx::InitWidget(this, IDC_EDIT_Clip_xR, iniField, L"Clip_xR", iniCurrentPath, 2400);
	mmTest_RollAngle.yT = xx::InitWidget(this, IDC_EDIT_Clip_yT, iniField, L"Clip_yT", iniCurrentPath, 0);
	mmTest_RollAngle.yD = xx::InitWidget(this, IDC_EDIT_Clip_yD, iniField, L"Clip_yD", iniCurrentPath, 2400);

	mmTest_RollAngle.ZoomScale = xx::InitWidget(this, IDC_EDIT_Zoom, iniField, L"ZoomScale", iniCurrentPath, float(4));

	mmTest_RollAngle.GaussSize = xx::InitWidget(this, IDC_EDIT_GaussSize, iniField, L"GaussSize", iniCurrentPath, 27);
	mmTest_RollAngle.GaussSigma = xx::InitWidget(this, IDC_EDIT_GaussSigma, iniField, L"GaussSigma", iniCurrentPath, float(3));

	mmTest_RollAngle.BinarySize = xx::InitWidget(this, IDC_EDIT_BinarySize, iniField, L"BinarySize", iniCurrentPath, 45);
	mmTest_RollAngle.BinaryC = xx::InitWidget(this, IDC_EDIT_BinaryC, iniField, L"BinaryC", iniCurrentPath, float(2));

	mmTest_RollAngle.SelDiateMorphShape = xx::InitCB(this, IDC_COMBO_DiateMorphShape, mmTest_RollAngle.vecMorphShapes, iniField, L"DiateMorphShape", iniCurrentPath, 2);
	mmTest_RollAngle.DilatekSize = xx::InitWidget(this, IDC_EDIT_DilatekSize, iniField, L"DilatekSize", iniCurrentPath, 17);
	mmTest_RollAngle.DilateNum = xx::InitWidget(this, IDC_EDIT_DilateNum, iniField, L"DilateNum", iniCurrentPath, 1);

	mmTest_RollAngle.SelErodeMorphShape = xx::InitCB(this, IDC_COMBO_ErodeMorphShape, mmTest_RollAngle.vecMorphShapes, iniField, L"ErodeMorphShape", iniCurrentPath, 2);
	mmTest_RollAngle.ErodekSize = xx::InitWidget(this, IDC_EDIT_ErodekSize, iniField, L"ErodekSize", iniCurrentPath, 17);
	mmTest_RollAngle.ErodeNum = xx::InitWidget(this, IDC_EDIT_ErodeNum, iniField, L"ErodeNum", iniCurrentPath, 1);

	mmTest_RollAngle.PixelMinDist = xx::InitWidget(this, IDC_EDIT_PixelMinDist, iniField, L"PixelMinDist", iniCurrentPath, float(20));
	mmTest_RollAngle.PixelPara1 = xx::InitWidget(this, IDC_EDIT_PixelPara1, iniField, L"PixelPara1", iniCurrentPath, float(20));
	mmTest_RollAngle.PixelPara2 = xx::InitWidget(this, IDC_EDIT_PixelPara2, iniField, L"PixelPara2", iniCurrentPath, float(10));
	mmTest_RollAngle.PixelMinRadius = xx::InitWidget(this, IDC_EDIT_PixelMinRadius, iniField, L"PixelMinRadius", iniCurrentPath, 19);
	mmTest_RollAngle.PixelMaxRadius = xx::InitWidget(this, IDC_EDIT_PixelMaxRadius, iniField, L"PixelMaxRadius", iniCurrentPath, 21);

	mmTest_RollAngle.InitXcOffset = xx::InitWidget(this, IDC_EDIT_InitXcOffset, iniField, L"InitXcOffset", iniCurrentPath, 0);
	mmTest_RollAngle.InitYcOffset = xx::InitWidget(this, IDC_EDIT_InitYcOffset, iniField, L"InitYcOffset", iniCurrentPath, 0);

	mmTest_RollAngle.FitMinAngle = xx::InitWidget(this, IDC_EDIT_FitMinAngle, iniField, L"FitMinAngle", iniCurrentPath, float(-20));
	mmTest_RollAngle.FitMaxAngle = xx::InitWidget(this, IDC_EDIT_FitMaxAngle, iniField, L"FitMaxAngle", iniCurrentPath, float(20));
	mmTest_RollAngle.FitMinDis = xx::InitWidget(this, IDC_EDIT_FitMinDis, iniField, L"FitMinDis", iniCurrentPath, float(2));
	mmTest_RollAngle.FitMaxDis = xx::InitWidget(this, IDC_EDIT_FitMaxDis, iniField, L"FitMaxDis", iniCurrentPath, float(200));

	mmTest_RollAngle.Offset = xx::InitWidget(this, IDC_EDIT_Offset, iniField, L"Offset", iniCurrentPath, float(0));

	return TRUE;
}


void CTest_RollAngle_Dlg::OnBnClickedButtonSave()
{
	CString iniField = mmTest_RollAngle.iniField;
	CString iniCurrentPath = mmFile_Paras.iniModelPath();

	mmTest_RollAngle.SelStep = xx::DefaultCB(this, IDC_COMBO_StepName, iniField, L"SelStep", iniCurrentPath, 0);
	mmTest_RollAngle.xL = xx::DefaultWidget(this, IDC_EDIT_Clip_xL, iniField, L"Clip_xL", iniCurrentPath, 0);
	mmTest_RollAngle.xR = xx::DefaultWidget(this, IDC_EDIT_Clip_xR, iniField, L"Clip_xR", iniCurrentPath, 0);
	mmTest_RollAngle.yT = xx::DefaultWidget(this, IDC_EDIT_Clip_yT, iniField, L"Clip_yT", iniCurrentPath, 0);
	mmTest_RollAngle.yD = xx::DefaultWidget(this, IDC_EDIT_Clip_yD, iniField, L"Clip_yD", iniCurrentPath, 0);

	mmTest_RollAngle.ZoomScale = xx::DefaultWidget(this, IDC_EDIT_Zoom, iniField, L"ZoomScale", iniCurrentPath, float(0));

	mmTest_RollAngle.GaussSize = xx::DefaultWidget(this, IDC_EDIT_GaussSize, iniField, L"GaussSize", iniCurrentPath, 0);
	mmTest_RollAngle.GaussSigma = xx::DefaultWidget(this, IDC_EDIT_GaussSigma, iniField, L"GaussSigma", iniCurrentPath, float(0));

	mmTest_RollAngle.BinarySize = xx::DefaultWidget(this, IDC_EDIT_BinarySize, iniField, L"BinarySize", iniCurrentPath, 0);
	mmTest_RollAngle.BinaryC = xx::DefaultWidget(this, IDC_EDIT_BinaryC, iniField, L"BinaryC", iniCurrentPath, float(0));

	mmTest_RollAngle.SelDiateMorphShape = xx::DefaultCB(this, IDC_COMBO_DiateMorphShape, iniField, L"DiateMorphShape", iniCurrentPath, 0);
	mmTest_RollAngle.DilatekSize = xx::DefaultWidget(this, IDC_EDIT_DilatekSize, iniField, L"DilatekSize", iniCurrentPath, 0);
	mmTest_RollAngle.DilateNum = xx::DefaultWidget(this, IDC_EDIT_DilateNum, iniField, L"DilateNum", iniCurrentPath, 0);

	mmTest_RollAngle.SelErodeMorphShape = xx::DefaultCB(this, IDC_COMBO_ErodeMorphShape, iniField, L"ErodeMorphShape", iniCurrentPath, 0);
	mmTest_RollAngle.ErodekSize = xx::DefaultWidget(this, IDC_EDIT_ErodekSize, iniField, L"ErodekSize", iniCurrentPath, 0);
	mmTest_RollAngle.ErodeNum = xx::DefaultWidget(this, IDC_EDIT_ErodeNum, iniField, L"ErodeNum", iniCurrentPath, 0);

	mmTest_RollAngle.PixelMinDist = xx::DefaultWidget(this, IDC_EDIT_PixelMinDist, iniField, L"PixelMinDist", iniCurrentPath, float(0));
	mmTest_RollAngle.PixelPara1 = xx::DefaultWidget(this, IDC_EDIT_PixelPara1, iniField, L"PixelPara1", iniCurrentPath, float(0));
	mmTest_RollAngle.PixelPara2 = xx::DefaultWidget(this, IDC_EDIT_PixelPara2, iniField, L"PixelPara2", iniCurrentPath, float(0));
	mmTest_RollAngle.PixelMinRadius = xx::DefaultWidget(this, IDC_EDIT_PixelMinRadius, iniField, L"PixelMinRadius", iniCurrentPath, 0);
	mmTest_RollAngle.PixelMaxRadius = xx::DefaultWidget(this, IDC_EDIT_PixelMaxRadius, iniField, L"PixelMaxRadius", iniCurrentPath, 0);

	mmTest_RollAngle.InitXcOffset = xx::DefaultWidget(this, IDC_EDIT_InitXcOffset, iniField, L"InitXcOffset", iniCurrentPath, 0);
	mmTest_RollAngle.InitYcOffset = xx::DefaultWidget(this, IDC_EDIT_InitYcOffset, iniField, L"InitYcOffset", iniCurrentPath, 0);

	mmTest_RollAngle.FitMinAngle = xx::DefaultWidget(this, IDC_EDIT_FitMinAngle, iniField, L"FitMinAngle", iniCurrentPath, float(0));
	mmTest_RollAngle.FitMaxAngle = xx::DefaultWidget(this, IDC_EDIT_FitMaxAngle, iniField, L"FitMaxAngle", iniCurrentPath, float(0));
	mmTest_RollAngle.FitMinDis = xx::DefaultWidget(this, IDC_EDIT_FitMinDis, iniField, L"FitMinDis", iniCurrentPath, float(0));
	mmTest_RollAngle.FitMaxDis = xx::DefaultWidget(this, IDC_EDIT_FitMaxDis, iniField, L"FitMaxDis", iniCurrentPath, float(0));

	mmTest_RollAngle.Offset = xx::DefaultWidget(this, IDC_EDIT_Offset, iniField, L"Offset", iniCurrentPath, float(0));
}


void CTest_RollAngle_Dlg::OnEnChangeEditClipxl()
{
	mmTest_RollAngle.xL = xx::ReadWidget(this, IDC_EDIT_Clip_xL, 0);
}


void CTest_RollAngle_Dlg::OnEnChangeEditClipxr()
{
	mmTest_RollAngle.xR = xx::ReadWidget(this, IDC_EDIT_Clip_xR, 0);
}


void CTest_RollAngle_Dlg::OnEnChangeEditClipyt()
{
	mmTest_RollAngle.yT = xx::ReadWidget(this, IDC_EDIT_Clip_yT, 0);
}


void CTest_RollAngle_Dlg::OnEnChangeEditClipyd()
{
	mmTest_RollAngle.yD = xx::ReadWidget(this, IDC_EDIT_Clip_yD, 0);
}


void CTest_RollAngle_Dlg::OnCbnSelchangeComboStepname()
{
	mmTest_RollAngle.SelStep = ((CComboBox*)GetDlgItem(IDC_COMBO_StepName))->GetCurSel();
}
